package com.dqp.cslggroup.Calendar;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dqp.cslggroup.R;
import com.dqp.cslggroup.bean.CalendarEvent;

import java.util.List;

public class CalendarEventAdapter extends BaseAdapter {
    private List<CalendarEvent> events;
    private LayoutInflater inflater;


    CalendarEventAdapter(List<CalendarEvent> events, Context context) {
        this.events = events;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return events == null ? 0 : events.size();
    }

    @Override
    public Object getItem(int position) {
        return events.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        @SuppressLint({"ViewHolder", "InflateParams"}) View view = inflater.inflate(R.layout.college_item, null);
        CalendarEvent event = (CalendarEvent) getItem(position);
        TextView name = view.findViewById(R.id.college_name);
        TextView des = view.findViewById(R.id.college_des);
        TextView location = view.findViewById(R.id.college_profession);
        TextView alarm = view.findViewById(R.id.college_pv);
        des.setMaxLines(10);
        name.setText(event.getTitle());
        alarm.setText("提醒：提前" + event.getPreviousDate() + "分钟");
        location.setText(event.getLocation());
        des.setText(event.getDes());
        return view;
    }


}
